package com.you.rpc.entity;

import java.util.Objects;

public class RpcAddress {
    /**
     * 主机名:
     * localhost
     * 127.0.0.1
     */
    String host;
    /**
     * 端口号
     */
    int port;

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    @Override
    public int hashCode() {
        return Objects.hash(host, port);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        RpcAddress address = (RpcAddress) obj;
        return this.port == address.getPort() && this.host.equalsIgnoreCase(address.getHost());
    }

    @Override
    public String toString() {
        return "RpcAddress{" +
                "host='" + host + '\'' +
                ", port=" + port +
                '}';
    }
}
